const util = require('../../utils/util.js')
const common = require('../../utils/common.js')

Page({
  data: {
    addrs: [
      {
        id:1,
        name:'肖伟',
      phone:"13121118888" }, 
      {
        id: 2,
        name: '茂云',
        phone: "13121118888"
      }, 
      {
        id: 3,
        name: '张三',
        phone: "13121118888"
      }, 
    ]
  },
  toDetail: function (e) {
    console.log("todetail");
    var id = e.currentTarget.id,
      url = '/pages/detail/detail?id=' + id + '&name=' + e.currentTarget.dataset.name;

    wx.navigateTo({
      url: url
    })
  },
  toDel: function (e) {
    console.log("我要删除"+e.currentTarget.dataset.id);
    this.data.addrs.splice(e.currentTarget.dataset.id - 1, 1)
    this.setData({
      addrs: this.data.addrs
      })
  },
   toAdd: function () {
    console.log(this.data.addrs.length);
    let str='';
    for(let i=0;i<8;i++){
      str += common.radomNum();
    }
    this.data.addrs.push({
      id: this.data.addrs.length+1,
      name: 'js增加',
      phone: "131" + str
    });
    this.data.addrs.sli
    this.setData({
      addrs: this.data.addrs
      })
  }
})
